namespace BlogSystem.Models.Migrations
{
    using System;
    using System.Data.Entity.Migrations;
    
    public partial class createBlog : DbMigration
    {
        public override void Up()
        {
            CreateTable(
                "dbo.BaseEntities",
                c => new
                    {
                        Id = c.Guid(nullable: false),
                        CreateRime = c.DateTime(nullable: false),
                        IsRemoved = c.Boolean(nullable: false),
                        Title = c.String(),
                        Content = c.String(storeType: "ntext"),
                        UserId = c.Guid(),
                        GoodCount = c.Int(),
                        BadCount = c.Int(),
                        MyProperty = c.Int(),
                        Email = c.String(maxLength: 40, unicode: false),
                        Password = c.String(maxLength: 30, unicode: false),
                        ImagePath = c.String(maxLength: 300, unicode: false),
                        FansCount = c.Int(),
                        FocusCount = c.Int(),
                        SiteName = c.String(),
                        BlogCategoryId = c.Guid(),
                        ArticleId = c.Guid(),
                        CategoryName = c.String(),
                        UserId1 = c.Guid(),
                        UserId2 = c.Guid(),
                        Content1 = c.String(maxLength: 800),
                        ArticleId1 = c.Guid(),
                        UserId3 = c.Guid(),
                        FocusUserId = c.Guid(),
                        Discriminator = c.String(nullable: false, maxLength: 128),
                    })
                .PrimaryKey(t => t.Id)
                .ForeignKey("dbo.BaseEntities", t => t.UserId)
                .ForeignKey("dbo.BaseEntities", t => t.ArticleId)
                .ForeignKey("dbo.BaseEntities", t => t.UserId1)
                .ForeignKey("dbo.BaseEntities", t => t.BlogCategoryId)
                .ForeignKey("dbo.BaseEntities", t => t.ArticleId1)
                .ForeignKey("dbo.BaseEntities", t => t.UserId2)
                .ForeignKey("dbo.BaseEntities", t => t.FocusUserId)
                .ForeignKey("dbo.BaseEntities", t => t.UserId3)
                .Index(t => t.UserId)
                .Index(t => t.BlogCategoryId)
                .Index(t => t.ArticleId)
                .Index(t => t.UserId1)
                .Index(t => t.UserId2)
                .Index(t => t.ArticleId1)
                .Index(t => t.UserId3)
                .Index(t => t.FocusUserId);
            
        }
        
        public override void Down()
        {
            DropForeignKey("dbo.BaseEntities", "UserId3", "dbo.BaseEntities");
            DropForeignKey("dbo.BaseEntities", "FocusUserId", "dbo.BaseEntities");
            DropForeignKey("dbo.BaseEntities", "UserId2", "dbo.BaseEntities");
            DropForeignKey("dbo.BaseEntities", "ArticleId1", "dbo.BaseEntities");
            DropForeignKey("dbo.BaseEntities", "BlogCategoryId", "dbo.BaseEntities");
            DropForeignKey("dbo.BaseEntities", "UserId1", "dbo.BaseEntities");
            DropForeignKey("dbo.BaseEntities", "ArticleId", "dbo.BaseEntities");
            DropForeignKey("dbo.BaseEntities", "UserId", "dbo.BaseEntities");
            DropIndex("dbo.BaseEntities", new[] { "FocusUserId" });
            DropIndex("dbo.BaseEntities", new[] { "UserId3" });
            DropIndex("dbo.BaseEntities", new[] { "ArticleId1" });
            DropIndex("dbo.BaseEntities", new[] { "UserId2" });
            DropIndex("dbo.BaseEntities", new[] { "UserId1" });
            DropIndex("dbo.BaseEntities", new[] { "ArticleId" });
            DropIndex("dbo.BaseEntities", new[] { "BlogCategoryId" });
            DropIndex("dbo.BaseEntities", new[] { "UserId" });
            DropTable("dbo.BaseEntities");
        }
    }
}
